package com.raining.inningz.database;

import java.util.ArrayList;
import java.util.List;

import com.raining.inningz.constants.IDBConstants;
import com.raining.inningz.database.dao.DaoMaster;
import com.raining.inningz.database.dao.DaoMaster.DevOpenHelper;
import com.raining.inningz.database.dao.DaoSession;
import com.raining.inningz.database.dao.Matches;
import com.raining.inningz.database.dao.MatchesDao;
import com.raining.inningz.database.dao.MatchesDao.Properties;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;


public class DbManager {
	
	
	
	public static DaoSession getDbManager(Context context) {
		SQLiteDatabase db;

		DaoMaster daoMaster;
		DaoSession daoSession;
		DevOpenHelper helper = new DaoMaster.DevOpenHelper(context,IDBConstants.DB_NAME, null);
		db = helper.getWritableDatabase();
		daoMaster = new DaoMaster(db);
		return daoSession = daoMaster.newSession();
	}
	
	
	
	
	public static List<Matches> getMatch(String matchID,Context context){
		
		DaoSession daoSession=DbManager.getDbManager(context);
		
		MatchesDao matchesDao=daoSession.getMatchesDao();
		return matchesDao.queryBuilder().where(Properties.MatchId.eq(matchID)).list();
		
	}
	
	
	
	
	
	
	
	
	

}
